// DecProp.cpp: implementation of the CDecProp class.
//
//////////////////////////////////////////////////////////////////////
#include <streams.h>
#include <initguid.h>    // declares DEFINE_GUID to declare an EXTERN_C const.
#include <aviriff.h>
#define IDD_CONFIG                      101

#include "DecProp.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CDecProp::CDecProp(IUnknown* pUnk)
		: CBasePropertyPage(NAME("DecProp\0"), pUnk, IDD_CONFIG, 102),
		m_pDecPage(NULL)
{
//	m_nPropVideoFormat = FORMAT_CIF4 - 1;
	m_bConnnected = FALSE;	
}

CUnknown* WINAPI CDecProp::CreateInstance(LPUNKNOWN pUnk, HRESULT* pHr) 
{
	CUnknown *punk = new CDecProp(pUnk);
	
	if (NULL == punk) 
	{
		*pHr = E_OUTOFMEMORY;
	}
	
	return punk;
}

HRESULT CDecProp::OnConnect(IUnknown* pUnk)
{
    //if (NULL == pUnk)
	{
        return E_POINTER;
	}
	//m_bConnnected = TRUE;
	//return  pUnk->QueryInterface(IID_IRtpParamHandle, (void**)&m_pRtpParmInterface);
}

HRESULT CDecProp::OnDeactivate()
{
	return S_OK; 
}

HRESULT CDecProp::OnDisconnect()
{
	/*if (NULL != m_pRtpParmInterface)
	{
		m_pRtpParmInterface->Release();
		m_pRtpParmInterface = NULL;
	}*/
	return S_OK;
}

HRESULT CDecProp::OnActivate()
{
	HRESULT hr;

#if defined _DEBUG
	ASSERT(NULL != m_pRtpParmInterface);
#endif
  /*  SendDlgItemMessage(m_Dlg, IDC_VIDEO_FORMAT, CB_ADDSTRING, (WPARAM)0, (LPARAM)(TEXT("CIF4")));
	SendDlgItemMessage(m_Dlg, IDC_VIDEO_FORMAT, CB_ADDSTRING, (WPARAM)1, (LPARAM)(TEXT("CIF")));
	SendDlgItemMessage(m_Dlg, IDC_VIDEO_FORMAT, CB_ADDSTRING, (WPARAM)2, (LPARAM)(TEXT("QCIF")));
	SendDlgItemMessage(m_Dlg, IDC_VIDEO_FORMAT, CB_ADDSTRING, (WPARAM)3, (LPARAM)(TEXT("D1")));
	if (m_nPropVideoFormat <= 0)
	{
		SendDlgItemMessage(m_Dlg, IDC_VIDEO_FORMAT, CB_SETCURSEL, 0, 0);
		
	}*/
	// hr = m_pRtpParmInterface->get_VideoFormat(m_nPropVideoFormat);

	/*if (SUCCEEDED(hr))
	{
		SendDlgItemMessage(m_Dlg, IDC_VIDEO_FORMAT, CB_SETCURSEL, m_nPropVideoFormat-1, 0);
	}*/

	return hr;
}

HRESULT CDecProp::OnApplyChanges()
{
//	if (NULL == m_pRtpParmInterface)
//	{
//		return E_FAIL;
//	}

//	m_nPropVideoFormat = SendDlgItemMessage(m_Dlg, IDC_VIDEO_FORMAT, CB_GETCURSEL, 0, 0) + 1;

	// m_pRtpParmInterface->set_VideoFormat(m_nPropVideoFormat);
	return S_OK;
}

INT_PTR CDecProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wp, LPARAM lp)
{
	switch (uMsg)
	{
	case WM_INITDIALOG:
        {
            return (LRESULT) 1;
        }
		
	case WM_COMMAND:
        {
			m_bDirty = TRUE;
			if(NULL != m_pPageSite)
			{
				m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
			}
        }
		break;
	default:
		break;
	}

	return CBasePropertyPage::OnReceiveMessage(hwnd, uMsg, wp, lp);
}
